#!/bin/bash

#资源名称
RESOURCE_NAME=webservice
#启动端口
SERVER_PORT=8082

PID=$(ps -ef | grep $RESOURCE_NAME  | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
   echo $RESOURCE_NAME Application is already stopped
else
    kill -9 $PID
    echo  $RESOURCE_NAME Application stopped successfully  pid = $PID
fi

nohup java  -server  -Xms300m  -Xmx300m -Xss384k  -XX:+UseG1GC  -XX:MaxGCPauseMillis=200 \
-XX:+PrintGC  -XX:+PrintGCDetails -XX:+PrintGCDateStamps \
-XX:+HeapDumpOnOutOfMemoryError  -XX:HeapDumpPath=./java_error_in_idea.hprof \
-XX:+UnlockExperimentalVMOptions \
-jar $RESOURCE_NAME.jar \
--server.port=$SERVER_PORT \
>nohup.out 2>&1 &

#--spring.profiles.active=mysql-dev \
#>/dev/null 2>&1 &
#>/dev/null 2>nohup_err.out &
# >nohup.out 2>&1 &

echo $RESOURCE_NAME Application started successfully
